interface Props {
  id: string
  children: number[]
}
//将属性和方法变为可选项
type ParticalProps = Partial<Props>
let p1: Props = {
  id: 'aaaa',
  children: [1, 2, 3, 4]
}
let p2: ParticalProps = {
  id: 'asdsa'
}
//所有的属性和方法都为只读
type ReadonlyProps = Readonly<Props>
let p3: ReadonlyProps = {
  id: 'asdsa',
  children: [1, 2, 3, 4]
}
console.log(p3.children);

//选择属性
interface Props2 {
  id: string
  tiltle: string
  children: number[]
}
type PickProps2 = Pick<Props2, 'id' | 'children'>
let p4: PickProps2 = {
  id: '1001',
  children: [1, 2, 3, 4]
}
console.log(p4);

//记录属性简化类的创建（属性类型一致）
type RecordProps1 = Record<'a' | 'b' | 'c' | 'd', string[]>
let p5: RecordProps1 =
{
  a: ['1', 'a', 'c'],
  b: ['1', 'a', 'c'],
  c: ['1', 'a', 'c'],
  d: ['1', 'a', 'c']
}

console.log(p5);
